/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       automatic_spells.cpp

	$Header: /game/automatic_spells.cpp $

	$NoKeywords: $

 ************************************************************************/
#include "precompiled.h"
#include "automatic_spells.h"

#include "elements_of.h"
#include "spell.h"
#include "spell_properties.h"

static t_spell const k_starting_chaos_spells[] =
{
	k_spell_bloodlust,
	k_spell_burning_hands,
	k_spell_firebreathing,
	k_spell_haste,
	k_spell_magic_arrow
};

static t_spell const k_starting_death_spells[] =
{
	k_spell_curse,
	k_spell_poison,
	k_spell_raise_skeletons,
	k_spell_ray_of_suffering
};


static t_spell const k_starting_life_spells[] =
{
	k_spell_bind_wound,
	k_spell_bless,
	k_spell_holy_armor
};

static t_spell const k_starting_nature_spells[] =
{
	k_spell_nature_haste,
	k_spell_stoneskin,
	k_spell_summon_leprechaun,
	k_spell_summon_sprite,
	k_spell_summon_wolf,
};

static t_spell const k_starting_order_spells[] =
{
	k_spell_blur,
	k_spell_precision,
	k_spell_magic_fist
};

static t_spell const k_demonology_spells[] =
{
	k_spell_summon_imps,
	k_spell_summon_cerberi,
	k_spell_summon_ice_demon,
	k_spell_summon_venom_spawn,
	k_spell_summon_devils
};

static void add_spells( std::vector< t_automatic_spell_set >& spell_list, t_skill_type skill,
						t_spell const* spells, int spell_count )
{
	t_automatic_spell_set set;

	set.skill_requirements.push_back( t_skill( skill, k_mastery_basic ) );
	int i;

	for (i = 0; i < spell_count; ++i)
		set.spells.push_back( spells[i] );
	spell_list.push_back( set );
}

std::vector<t_automatic_spell_set> const& get_automatic_spells()
{
	static std::vector<t_automatic_spell_set> automatic_spells;
	static bool								  initialized = false;

	if (!initialized)
	{
		add_spells( automatic_spells, k_skill_chaos_magic, k_starting_chaos_spells, 
					ELEMENTS_OF( k_starting_chaos_spells ) );
		add_spells( automatic_spells, k_skill_death_magic, k_starting_death_spells, 
					ELEMENTS_OF( k_starting_death_spells ) );
		add_spells( automatic_spells, k_skill_life_magic, k_starting_life_spells, 
					ELEMENTS_OF( k_starting_life_spells ) );
		add_spells( automatic_spells, k_skill_nature_magic, k_starting_nature_spells, 
					ELEMENTS_OF( k_starting_nature_spells ) );
		add_spells( automatic_spells, k_skill_order_magic, k_starting_order_spells, 
					ELEMENTS_OF( k_starting_order_spells ) );

		// load demonology spells
		int i;

		for (i = 0; i < ELEMENTS_OF( k_demonology_spells ); ++i )
		{
			t_spell					spell = k_demonology_spells[i];
			int						level = get_spell_level( spell );
			t_automatic_spell_set	set;
			t_skill					skill;

			skill.skill = k_skill_nature_magic;
			skill.level = t_skill_mastery( level - 1 );
			set.skill_requirements.push_back( skill );
			skill.skill = k_skill_demonology;
			set.skill_requirements.push_back( skill );
			set.spells.push_back( spell );
			automatic_spells.push_back( set );
		}

		initialized = true;
	}
	return automatic_spells;
}

